import Vue from 'vue'
import Vuex from 'vuex'
import constData from './modules/constData'
Vue.use(Vuex);


const state = {
  headerTitle:'',
  deviceId:''
}

const getters = {
  getHeaderTitle: state => state.headerTitle,
  getDeviceId: state => state.deviceId
}

//mutattions对象里面可以放改变state的初始值的方法
const mutations = {

  setHeaderTitle(state,headerTitle){
    state.headerTitle = headerTitle
  },
  setDeviceId(state,deviceId){
    state.deviceId = deviceId
  }
}

const actions = {
  setHeaderTitle(context,headerTitle){
    context.commit('setHeaderTitle',headerTitle)
  },
  setDeviceId(context,deviceId){
    context.commit('setDeviceId',deviceId)
  }
}


const store = new Vuex.Store({
  state,
  getters,
  mutations,
  actions,
  modules: {
    constData
  }
});

export default store;
